/*
 * Copyright (c) Scrap Material Junior Brother, Xin. 2023-2023. All rights reserved.
 */

package util;

import link.MyLink;
import link.Node;

/**
 * 基础工具类
 *
 * @author xin
 * @since 2023-04-29
 */
public class BaseUtils {
    @FunctionalInterface
    public interface ClassMethod {
        /**
         * 打印方法内容
         *
         * @author code-worker
         * @since 2023/4/29 11:51
         */
        void method();
    }

    /**
     * 格式化打印数据
     *
     * @param apiName 方法名
     * @param classMethod 方法
     */
    public static void print(String apiName, ClassMethod classMethod) {
        System.out.println("API: " + apiName);
        classMethod.method();
        System.out.println("------------------");
        System.out.println("");
    }


    /**
     * 构造单链表节点数据
     *
     * @param data 数据
     * @return 单链表头节点
     */
    public static Node nodeData(int ... data) {
        MyLink link = new MyLink();
        for (int i : data) {
            link.addLast(i);
        }
        return link.head;
    }
}
